'use strict';

/**
 * 主账号微信 小程序，公众号 token 储存
 */

module.exports = app => {
  const { Sequelize, model } = app;
  const Model = model.define(
    'wx_app_token',
    {
      id: {
        type: Sequelize.STRING.BINARY,
        defaultValue: Sequelize.UUIDV1,
        primaryKey: true
      },
      app_name: {
        type: Sequelize.STRING(32),
        allowNull: false,
        unique: true
      },
      appid: {
        type: Sequelize.STRING(128),
        unique: true
      },
      access_token: {
        type: Sequelize.STRING(249),
        allowNull: false
      },
      expires_in: {
        type: Sequelize.INTEGER(8),
        defaultValue: 7200
      }
    },
    {
      freezeTableName: true,
      tableName: 'wx_app_token'
    }
  );

  return Model;
};
